#ifndef __GlSpriteDescriptionManager_h__
#define __GlSpriteDescriptionManager_h__

#include <vector>
#include "tinyxml2.h"

namespace GraphicLibrary
{
	class SpriteDescription;

	class SpriteDescriptionManager
	{
		public:
			enum ExceptionList
			{
				ElNotSpriteDescriptionDocument,
				ElDuplicatedSimbol,
				ElIncorrectSpriteDescription_MissingFrameDesc
			};

			~SpriteDescriptionManager();
			void addDescription(const char *descFileName);
			const SpriteDescription* getDesc(const char *name) const;

			inline static SpriteDescriptionManager* GetSingleton()
			{
				if(!msSingleton)
					msSingleton = new SpriteDescriptionManager();
				return msSingleton;
			}
		private:
			typedef std::vector<SpriteDescription*>	SpriteDescriptionArray;

			SpriteDescriptionArray	mDescriptions;
			static SpriteDescriptionManager*	msSingleton;

			SpriteDescriptionManager()
			{}
			SpriteDescriptionManager(const SpriteDescriptionManager &source);
			SpriteDescriptionArray::iterator findPlace(const char *name) const;
			void add(const tinyxml2::XMLElement *sprite);
			float getFloat(const tinyxml2::XMLElement *tag, const char *attrib) const;
			void fillDescription(SpriteDescription *desc, const tinyxml2::XMLElement *sprite) const;
	};
}

#endif // __GlSpriteDescriptionManager_h__
